package com.rt.easyjava.common.dozer.converter;

import com.rt.easyjava.common.utils.others.FenAndYuan;
import com.rt.easyjava.common.utils.others.StringUtils;
import org.dozer.DozerConverter;

/**
 * Created by wxy on 2017/9/13.
 */
public class FenAndYuan4IntConverter extends DozerConverter<Integer,String> {


    public FenAndYuan4IntConverter() {
        super(Integer.class, String.class);
    }

    @Override
    public String convertTo(Integer source, String destination) {
        if(source == null)return null;
        return FenAndYuan.fen2yuanStr(source);
    }

    @Override
    public Integer convertFrom(String source, Integer destination) {
        if(StringUtils.isNull(source))return null;
        return Integer.parseInt(String.valueOf(FenAndYuan.yuan2fenLng(source)));
    }
}
